<html>
<head><meta charset="utf-8"><title>Example of a public-facing API? · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html">Example of a public-facing API?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="234719428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234719428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234719428">(Apr 15 2021 at 17:29)</a>:</h4>
<p>I've been reading the discussion of safe transmute, and I'm interested in the subject of stability. I get the impression that it's a bit of a sore subject that <span class="user-mention" data-user-id="219211">@Jack Wrenn</span> kind of wants to leave aside for now, but I think there are some aspects of the debate that haven't been well-explored.</p>
<p>Just to summarize my understanding: Jack's position is that API stability relative to transmute isn't an immediate concern, because it can be addressed as a pure library implementation, once a non-API-stable intrinsic has been added. Since safety is the part that needs an intrinsic, debates about stability should be deferred until safety is figured out.</p>
<p>I don't completely agree with the above view, but it's hard to make my argument without being sure what everyone's position is.</p>
<p>My question is: imagine that <code>BikeshedIntrinsicFrom</code> is stabilized (and miraculously keeps its name); what might an example of a public-facing, SemVer-aware API using the intrinsic look like? Obviously what I said earlier applies and it's hard to guess what the public-facing APIs should be before the foundations are laid out, but even a vague example would be helpful.</p>
<p>To be more specific, given the following code:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// In our case, zeroed is a freestanding function, not a trait method</span>
<span class="k">use</span><span class="w"> </span><span class="n">my_zerocopy</span>::<span class="n">zeroed</span><span class="p">;</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">MyCustomType</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ...</span>
<span class="p">}</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">my_value</span><span class="w"> </span>: <span class="nc">MyCustomType</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zeroed</span><span class="p">();</span><span class="w"></span>
</code></pre></div>
<p>what should the <code>zeroed()</code> function look like so that the above code compiles? (assuming MyCustomType is indeed safe to transmute from zeroes)</p>



<a name="234720119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720119">(Apr 15 2021 at 17:33)</a>:</h4>
<p>There's an example of one SemVer-aware abstraction here: <a href="https://jswrenn.github.io/transmutation-foundation/use-case-abstraction.html">https://jswrenn.github.io/transmutation-foundation/use-case-abstraction.html</a></p>



<a name="234720194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720194">(Apr 15 2021 at 17:33)</a>:</h4>
<p>Sure</p>



<a name="234720227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720227">(Apr 15 2021 at 17:34)</a>:</h4>
<p>Check out the other sections of that write-up too, if you haven't yet.</p>



<a name="234720324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720324">(Apr 15 2021 at 17:34)</a>:</h4>
<p>I have</p>



<a name="234720331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720331">(Apr 15 2021 at 17:34)</a>:</h4>
<p>That abstraction doesn't use Context, though.</p>



<a name="234720367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720367">(Apr 15 2021 at 17:34)</a>:</h4>
<p>I'm not sure how deliberate that is.</p>



<a name="234720445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720445">(Apr 15 2021 at 17:35)</a>:</h4>
<p>(especially given that the <code>FromZeros</code> implementation in the MCP does use Context)</p>



<a name="234720635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720635">(Apr 15 2021 at 17:36)</a>:</h4>
<p>It's deliberate for /that/ example. <code>Context</code> need not appear in all abstractions over BikeshedTransmutableFrom.</p>



<a name="234720668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720668">(Apr 15 2021 at 17:36)</a>:</h4>
<p>I think it makes sense for some abstractions, but not all.</p>



<a name="234720709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720709">(Apr 15 2021 at 17:36)</a>:</h4>
<p>The foundational api will support both kinds of abstractions.</p>



<a name="234720835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720835">(Apr 15 2021 at 17:37)</a>:</h4>
<p>I see. So there won't be a "canonical" SemVer-aware API?</p>



<a name="234720856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720856">(Apr 15 2021 at 17:37)</a>:</h4>
<p>Hopefully eventually!!</p>



<a name="234720975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234720975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234720975">(Apr 15 2021 at 17:38)</a>:</h4>
<p>It'll be easier to figure out what that might look like after landing the std::mem intrinsic.</p>



<a name="234721057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234721057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234721057">(Apr 15 2021 at 17:39)</a>:</h4>
<p>Possibly, it could be a situation where the community coalescence around a solution published as a crate, and that solution finds its way into the standard library</p>



<a name="234721083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234721083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234721083">(Apr 15 2021 at 17:39)</a>:</h4>
<p>Okay. Just to be clear, I have problems with a Muckable API, and I'm trying to explain them progressively, Socrates-style, because I don't want to jump to conclusions</p>



<a name="234721202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234721202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234721202">(Apr 15 2021 at 17:40)</a>:</h4>
<p>Basically, Muckable is all-or-nothing.</p>



<a name="234721350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234721350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234721350">(Apr 15 2021 at 17:41)</a>:</h4>
<p>Like, there's no way to say "the module <code>nuclear_plant</code> is allowed to transmute the type <code>nuclear_plant::Uranium</code>, but outside code isn't" using that trait.</p>



<a name="234721888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234721888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234721888">(Apr 15 2021 at 17:44)</a>:</h4>
<p>You can always do that with <code>BikeshedTransmutableFrom</code>; but if a serialization crate uses <code>Muckable</code>; there's no way to say "I want <code>nuclear_plant</code> to be able to pass <code>Uranium</code> to <code>my_serde</code>, but I don't want outside code to be able to do that". (because my_serde uses Muckable, not BikeshedTransmutableFrom)</p>



<a name="234722007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234722007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234722007">(Apr 15 2021 at 17:45)</a>:</h4>
<p>Does that seem relevant so far?</p>



<a name="234723568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234723568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234723568">(Apr 15 2021 at 17:56)</a>:</h4>
<p>Yep! To me, that's the biggest shortcoming of that API, but it doesn't bother some people, because you can mostly sneak your way out that bind by wrapping your fields in a private type, and implementing Muckable on that instead.</p>



<a name="234724010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234724010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234724010">(Apr 15 2021 at 17:59)</a>:</h4>
<p>The thing is, the BikeshedTransmutableFrom has similar problems; and so does the FromZeroes implementation in the MCP.</p>



<a name="234724516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234724516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234724516">(Apr 15 2021 at 18:02)</a>:</h4>
<p>Like. Simplest example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">foobar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Foobar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">foo</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Foo</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bar</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Bar</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="234724907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234724907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234724907">(Apr 15 2021 at 18:04)</a>:</h4>
<p>Given the definition of <code>FromZeros</code> in the MCP, there's no checked way to declare that Foobar implements FromZeros</p>



<a name="234725136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725136">(Apr 15 2021 at 18:06)</a>:</h4>
<p>Though I guess you can use <code>Assume::VISIBILITY</code></p>



<a name="234725405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725405">(Apr 15 2021 at 18:08)</a>:</h4>
<p>Yep. The example in the MCP has FromZeros as a blanket impl, so to "declare" that a type implements FromZeros, you'd simply write a test case demonstrating that it did. The static_assertions crate is great for this.</p>



<a name="234725557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725557">(Apr 15 2021 at 18:08)</a>:</h4>
<p>I feel like you're missing my point a bit</p>



<a name="234725646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725646">(Apr 15 2021 at 18:09)</a>:</h4>
<p>Er, sorry. I'm just now getting back to my laptop so perhaps I can read what you're saying a bit more closely.</p>



<a name="234725682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725682">(Apr 15 2021 at 18:09)</a>:</h4>
<p>Np, it's abstract stuff</p>



<a name="234725755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725755">(Apr 15 2021 at 18:09)</a>:</h4>
<p>Okay, take the FromZeros example; in an actual public API, you wouldn't use blanket impls, right?</p>



<a name="234725809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725809">(Apr 15 2021 at 18:10)</a>:</h4>
<p>Like</p>



<a name="234725890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234725890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234725890">(Apr 15 2021 at 18:10)</a>:</h4>
<p>Say you have a safe <code>my_zerocopy::zeroed()</code> freestanding function</p>



<a name="234726271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234726271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234726271">(Apr 15 2021 at 18:13)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">zeroed</span><span class="o">&lt;</span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">ASSUME</span>: <span class="nc">Assume</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Dst</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">BikeshedIntrinsicFrom</span><span class="o">&lt;</span><span class="p">[</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="kt">usize</span>::<span class="n">MAX</span><span class="p">],</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">ASSUME</span><span class="o">&gt;</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">mem</span>::<span class="n">transmute</span><span class="p">([</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">Dst</span><span class="o">&gt;</span><span class="p">])</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="234726436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234726436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234726436">(Apr 15 2021 at 18:14)</a>:</h4>
<p>The above function is definitely unsound. Because you can pass it an arbitrary Assume, and tell it "don't worry, just transmute this stuff, I'm 100% sure it's safe" even if it isn't, in safe code.</p>



<a name="234726756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234726756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234726756">(Apr 15 2021 at 18:16)</a>:</h4>
<p>I'm not quite sure what you mean by "actual public API". A crate like <code>zerocopy</code> <em>would</em> probably define a public API like:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">FromZeros</span><span class="o">&lt;</span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">ASSUME</span>: <span class="nc">Assume</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="sd">/// Safely initialize `Self` from zeroed bytes.</span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">zeroed</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[repr(u8)]</span><span class="w"></span>
<span class="k">enum</span> <span class="nc">Zero</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Zero</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="k">u8</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">unsafe</span><span class="w"> </span><span class="k">impl</span><span class="o">&lt;</span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">ASSUME</span>: <span class="nc">Assume</span><span class="o">&gt;</span><span class="w"> </span><span class="n">FromZeros</span><span class="o">&lt;</span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">ASSUME</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Dst</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">BikeshedIntrinsicFrom</span><span class="o">&lt;</span><span class="p">[</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="kt">usize</span>::<span class="n">MAX</span><span class="p">],</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">ASSUME</span><span class="o">&gt;</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">zeroed</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">mem</span>::<span class="n">transmute</span><span class="p">([</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="n">size_of</span>::<span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">])</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="kr">macro</span><span class="w"> </span><span class="n">zeroed</span><span class="p">()</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">struct</span> <span class="nc">Context</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="n">FromZeros</span>::<span class="o">&lt;</span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">Assume</span>::<span class="n">NOTHING</span><span class="o">&gt;</span>::<span class="n">zeroed</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="234726826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234726826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234726826">(Apr 15 2021 at 18:17)</a>:</h4>
<p>Right, okay, that answers my initial question (what would the api be like)</p>



<a name="234726872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234726872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234726872">(Apr 15 2021 at 18:17)</a>:</h4>
<p>But then the bit earlier still applies</p>



<a name="234726944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234726944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234726944">(Apr 15 2021 at 18:18)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">foobar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Foobar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">foo</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Foo</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bar</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Bar</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="234727046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727046">(Apr 15 2021 at 18:19)</a>:</h4>
<p>You can't do</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">foobar</span><span class="w"> </span>: <span class="nc">Foobar</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zeroed</span><span class="o">!</span><span class="p">();</span><span class="w"></span>
</code></pre></div>



<a name="234727145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727145">(Apr 15 2021 at 18:20)</a>:</h4>
<p>Why's that?</p>



<a name="234727230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727230">(Apr 15 2021 at 18:20)</a>:</h4>
<p>ah</p>



<a name="234727248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727248">(Apr 15 2021 at 18:20)</a>:</h4>
<p>the private fields.</p>



<a name="234727288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727288">(Apr 15 2021 at 18:20)</a>:</h4>
<p>well, it depends on /where/ you wrote <code>let foobar : Foobar = zeroed!();</code> then</p>



<a name="234727292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727292">(Apr 15 2021 at 18:20)</a>:</h4>
<p>Cause the fields in <code>Foobar</code>are private, and your macro uses <code>Assume::NOTHING</code></p>



<a name="234727309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727309">(Apr 15 2021 at 18:20)</a>:</h4>
<p>Yup</p>



<a name="234727467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727467">(Apr 15 2021 at 18:21)</a>:</h4>
<p>But in principle, I think Foobar should be able to say "I export the fact that my fields can be transmuted from zeroes, but not the actual fields themselves"</p>



<a name="234727587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727587">(Apr 15 2021 at 18:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="263609">Olivier FAURE</span> <a href="#narrow/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F/near/234727309">said</a>:</p>
<blockquote>
<p>Yup</p>
</blockquote>
<p>That seems fine. That transmutation wouldn't be sound in a context where the fields of <code>Foobar</code> aren't visible, so it's appropriate that the blanket <code>FromZeros</code> impl wouldn't hold here.</p>



<a name="234727611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727611">(Apr 15 2021 at 18:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="263609">Olivier FAURE</span> <a href="#narrow/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F/near/234727467">said</a>:</p>
<blockquote>
<p>But in principle, I think Foobar should be able to say "I export the fact that my fields can be transmuted from zeroes, but not the actual fields themselves"</p>
</blockquote>
<p>this is achievable with a touch of indirection <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="234727634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727634">(Apr 15 2021 at 18:23)</a>:</h4>
<p>You mean newtypes?</p>



<a name="234727837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727837">(Apr 15 2021 at 18:24)</a>:</h4>
<p>nope! i mean if we take the associated function out of <code>FromZeros</code>, we can add the <code>#[marker]</code> attribute to it, which would let <code>FooBar</code>'s author add their own implementation of <code>FromZeros</code> /just/ for <code>Foobar</code>.</p>



<a name="234727918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234727918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234727918">(Apr 15 2021 at 18:24)</a>:</h4>
<p>(there's actually a proposal to allow <code>#[marker]</code> on traits with all items defaulted, so removing the associated function might not even be necessary compromise in the future)</p>



<a name="234728042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728042">(Apr 15 2021 at 18:25)</a>:</h4>
<p>It's still all-or-nothing though, if I'm following you correctly</p>



<a name="234728173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728173">(Apr 15 2021 at 18:26)</a>:</h4>
<p>Quoting my earlier post:</p>
<blockquote>
<p>Like, there's no way to say "the module <code>nuclear_plant</code> is allowed to transmute the type <code>nuclear_plant::Uranium</code>, but outside code isn't" using that trait. You can always do that with <code>BikeshedTransmutableFrom</code>; but if a serialization crate uses <code>Muckable</code>; there's no way to say "I want <code>nuclear_plant</code> to be able to pass <code>Uranium</code> to <code>my_serde</code>, but I don't want outside code to be able to do that". (because my_serde uses Muckable, not BikeshedTransmutableFrom)</p>
</blockquote>



<a name="234728437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728437">(Apr 15 2021 at 18:28)</a>:</h4>
<p>Because if you add the <code>FromZeros</code> marker trait to <code>Uranium</code>, then any API that can access Uranium can deserialize it from zeroes, even if you want to reserve that for a single SemVer context.</p>



<a name="234728459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728459">(Apr 15 2021 at 18:28)</a>:</h4>
<p>what's the "all" and what's the "nothing"? </p>
<p>If <code>FromZeros</code> has <code>#[marker]</code> you get the best of both worlds:</p>
<ul>
<li>a <code>FromZeros</code> impl is automatically available in all contexts where the fields of <code>Foobar</code> are visible</li>
<li>and you can also <em>manually</em> implement <code>FromZeros</code> for <code>Foobar</code> so that it has a <code>FromZeros</code> impl even in contexts where tis fields aren't visible</li>
</ul>



<a name="234728601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728601">(Apr 15 2021 at 18:29)</a>:</h4>
<p>Mh</p>



<a name="234728841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728841">(Apr 15 2021 at 18:30)</a>:</h4>
<p>Going back to the stability argument, there are cases where you want to export a type's fields, but not the fact that it can be deserialized from zeroes.</p>



<a name="234728846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728846">(Apr 15 2021 at 18:31)</a>:</h4>
<p>What you're describing is a tricky situation to be sure, but I don't <em>think</em> it's intractable.</p>
<p>If you wanted <code>FromZeros</code> on <code>Foobar</code> in a <em>particular</em> context (but not all contexts) that does not have visibility in its fields, then you<br>
 1) add <code>enum Context {}</code> to the semver context in question<br>
 2) impl <code>FromZeros</code> on <code>FooBar</code> using that aforementioned context</p>



<a name="234728856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234728856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234728856">(Apr 15 2021 at 18:31)</a>:</h4>
<p>(though I admit that's a weaker argument)</p>



<a name="234729097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234729097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234729097">(Apr 15 2021 at 18:32)</a>:</h4>
<p>In the case of <code>FromZeroes</code> as described here, these issues are one-in-the-same.  Remember that the visibility requirement is recursive. If you have <em>that</em> much visibility into a public type, whether it can be instantiated from zeros is <em>already</em> a semver guarantee.</p>



<a name="234729349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234729349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234729349">(Apr 15 2021 at 18:34)</a>:</h4>
<blockquote>
<p>If you have that much visibility into a public type, whether it can be instantiated from zeros is already a semver guarantee.</p>
</blockquote>
<p>Not necessarily. It could be non_exhaustive, and add a non-zeroable field later. Doesn't normally break semver.</p>



<a name="234729597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234729597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234729597">(Apr 15 2021 at 18:35)</a>:</h4>
<p>Sorry, I used "visibility" as a shorthand.  The actual property is that the type is fully implicitly constructible. The RFC was clear on that point, but I don't recall if the MCP was.  You're totally right that <code>non_exhaustive</code> needs to be factored into that evaluation!</p>



<a name="234729796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234729796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234729796">(Apr 15 2021 at 18:36)</a>:</h4>
<p>Oh, right, non_exhaustive stops you from building a struct</p>



<a name="234729853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234729853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234729853">(Apr 15 2021 at 18:37)</a>:</h4>
<p>I always forget that</p>



<a name="234731390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234731390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234731390">(Apr 15 2021 at 18:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F/near/234728846">said</a>:</p>
<blockquote>
<p>If you wanted <code>FromZeros</code> on <code>Foobar</code> in a <em>particular</em> context (but not all contexts) that does not have visibility in its fields, then you<br>
 1) add <code>enum Context {}</code> to the semver context in question<br>
 2) impl <code>FromZeros</code> on <code>FooBar</code> using that aforementioned context</p>
</blockquote>
<p>So just to be clear: to "export" a FromZeros implementation,  you create a marker type <code>enum Context {}</code> ; you implement the marker trait <code>FromZeroes</code> conditional on access to Context; because it's an <code>unsafe impl</code>, you can get away with breaking visibility; because you "control" the underlying type, you can't make sure the unsafe isn't unsound.</p>
<p>So if a safe API (eg <code>zeroed!()</code>) wants to create our custom type, it needs to "prove" it can access the Context marker; as long as it can, the transmutation is guaranteed to be safe.</p>



<a name="234731554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234731554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234731554">(Apr 15 2021 at 18:48)</a>:</h4>
<p>(it's funny, every time I glaze over your user icon my brain think it's looking at a portrait of Cave Johnson; not sure why)</p>



<a name="234731721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234731721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234731721">(Apr 15 2021 at 18:50)</a>:</h4>
<p>This feels like it would violate trait coherence rules; but there's probably a way to make it work. I agree that it's not intractable.</p>



<a name="234732083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234732083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234732083">(Apr 15 2021 at 18:52)</a>:</h4>
<p>What's interesting to me in your example is the <code>enum Context {};</code> bit. I think it's a misnomer, so I'm gonna call it <code>enum FromZeroesMarker {}</code>.</p>



<a name="234732410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234732410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234732410">(Apr 15 2021 at 18:54)</a>:</h4>
<p>In the MCP, the stated rule is:</p>
<ul>
<li>Given a locally declared <code>Context</code>, you can transmute <code>T</code> iff <code>Context</code> can reach <code>T</code>'s fields.</li>
</ul>
<p>But here, you're implying a new rule, which is:</p>
<ul>
<li>Given a locally declared <code>Context</code>, you can transmute <code>T</code> if <code>Context</code> can reach <code>T</code>'s fields <strong>or a specially declared marker</strong> (eg FromZeroesMarker)</li>
</ul>



<a name="234732533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234732533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234732533">(Apr 15 2021 at 18:55)</a>:</h4>
<p>And the way you prove it has access to the <code>Context</code> marker is by supplying it! <a href="https://jack.wrenn.fyi/blog/private-trait-impls/">This pattern to scope trait implementations falls neatly out of type privacy.</a></p>
<p>The orphan rule does impose some limitations. E.g., if you're <em>manually</em> impl'ing <code>FromZeros</code> on a particular type only in a particular context, the type you're implementing that trait for <em>and</em> the private type representing that context <em>both</em> need to be in the same crate, <em>and</em> both visible from at least one scope in that crate (where so you can write out the <code>impl</code> there.)</p>



<a name="234732905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234732905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234732905">(Apr 15 2021 at 18:58)</a>:</h4>
<p>I don't think that's a different rule? <code>Context</code> just needs to be a private type. IMO, the most idiomatic thing to do is to slap down a one-off <code>enum Context {}</code> type in the place you want to check transmutability in, but you could also use an existing private type if one's available.</p>



<a name="234732974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234732974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234732974">(Apr 15 2021 at 18:58)</a>:</h4>
<blockquote>
<p>When visibility is enforced, <code>Context</code> must be instantiated with any private (i.e., <code>pub(self)</code> type. The compiler pretends that it is at the defining scope of that type, and checks that the necessary fields of <code>Src</code> and <code>Dst</code> are visible.</p>
</blockquote>



<a name="234733011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234733011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234733011">(Apr 15 2021 at 18:58)</a>:</h4>
<p>I think you've lost me</p>



<a name="234733018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234733018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234733018">(Apr 15 2021 at 18:58)</a>:</h4>
<p>Hold on</p>



<a name="234733573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234733573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234733573">(Apr 15 2021 at 19:02)</a>:</h4>
<p>Ok, say we have this:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">nuclear_plant</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Uranium</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">foo</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Foo</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bar</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Bar</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span>: <span class="nc">Uranium</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zeroed</span><span class="o">!</span><span class="p">();</span><span class="w"></span>
</code></pre></div>



<a name="234733653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234733653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234733653">(Apr 15 2021 at 19:02)</a>:</h4>
<p>How do you use your ContextMarker to implement FromZeros, in such a way that the last line is valid?</p>



<a name="234734369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234734369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234734369">(Apr 15 2021 at 19:07)</a>:</h4>
<p>Oh</p>



<a name="234734579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234734579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234734579">(Apr 15 2021 at 19:08)</a>:</h4>
<p>Wait, I get that you meant. You were saying that by declaring <code>enum Context</code> inside <code>nuclear_plant</code>, you can have it implement <code>FromZeros</code> only within that module.</p>



<a name="234734779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234734779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234734779">(Apr 15 2021 at 19:09)</a>:</h4>
<p>yep!</p>



<a name="234734877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234734877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234734877">(Apr 15 2021 at 19:10)</a>:</h4>
<p>let me just paste in the longer answer I just typed up, too, for posterity...</p>



<a name="234735330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234735330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234735330">(Apr 15 2021 at 19:13)</a>:</h4>
<p>This starting point:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">nuclear_plant</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[repr(C)]</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Uranium</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">foo</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Foo</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bar</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Bar</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span>: <span class="nc">Uranium</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zeroed</span><span class="o">!</span><span class="p">();</span><span class="w"></span>
</code></pre></div>
<p>...expands to:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">nuclear_plant</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[repr(C)]</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Uranium</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">foo</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Foo</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">bar</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Bar</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span>: <span class="nc">Uranium</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">struct</span> <span class="nc">ExampleContext</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">FromZeros</span>::<span class="o">&lt;</span><span class="n">ExampleContext</span><span class="p">,</span><span class="w"> </span><span class="n">Assume</span>::<span class="n">NOTHING</span><span class="o">&gt;</span>::<span class="n">zeroed</span><span class="p">()</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
</code></pre></div>
<p>The compiler now needs to assess whether <code>Uranium: FromZeros::&lt;Context, Assume::NOTHING&gt;</code>.</p>
<p>It find this blanket impl:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">unsafe</span><span class="w"> </span><span class="k">impl</span><span class="o">&lt;</span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">ASSUME</span>: <span class="nc">Assume</span><span class="o">&gt;</span><span class="w"> </span><span class="n">FromZeros</span><span class="o">&lt;</span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">ASSUME</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Dst</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Dst</span>: <span class="nc">BikeshedIntrinsicFrom</span><span class="o">&lt;</span><span class="p">[</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="kt">usize</span>::<span class="n">MAX</span><span class="p">],</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">ASSUME</span><span class="o">&gt;</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">zeroed</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">mem</span>::<span class="n">transmute</span><span class="p">([</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="n">size_of</span>::<span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">])</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>...and <em>then</em>, substituting in concrete types, must check whether the <code>where</code> bound holds:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Uranium</span>: <span class="nc">BikeshedIntrinsicFrom</span><span class="o">&lt;</span><span class="p">[</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="kt">usize</span>::<span class="n">MAX</span><span class="p">],</span><span class="w"> </span><span class="n">ExampleContext</span><span class="p">,</span><span class="w"> </span><span class="n">Assume</span>::<span class="n">NOTHING</span><span class="o">&gt;</span><span class="w"></span>
</code></pre></div>
<p>To answer whether this <code>where</code> bound holds, the compiler checks both that:</p>
<ol>
<li>is a sufficient supply of zeroed bytes a bit-valid instance of <code>Uranium</code> (yes!)</li>
<li>from the defining scope of <code>Context</code>, is <code>Uranium</code> fully-implicitly constructible (no!)</li>
</ol>
<p>You can prove that the visibility requirement is <em>not</em> met by replacing:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span>: <span class="nc">Uranium</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zeroed</span><span class="o">!</span><span class="p">();</span><span class="w"></span>
</code></pre></div>
<p>...with the implicit constructor expression:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nuclear_plant</span>::<span class="n">Uranium</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span>: <span class="nb">None</span><span class="p">,</span><span class="w"> </span><span class="n">bar</span>: <span class="nb">None</span> <span class="p">};</span><span class="w"> </span><span class="c1">// Compile Error!</span>
</code></pre></div>
<p>...which produces a compile error because <code>foo</code> and <code>bar</code> aren't visible.</p>



<a name="234735379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234735379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234735379">(Apr 15 2021 at 19:13)</a>:</h4>
<p>(also, yeah, in that case, there's no trait coherence problem)</p>



<a name="234735752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234735752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234735752">(Apr 15 2021 at 19:15)</a>:</h4>
<p>But we come back to what I was saying originally. There's no way to export a type's fields and its "transmutability" independently of one another</p>



<a name="234736002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234736002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234736002">(Apr 15 2021 at 19:17)</a>:</h4>
<p>To put it concisely, there's no way to express</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// This is fine</span>
<span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span>: <span class="nc">Uranium</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zeroed</span><span class="o">!</span><span class="p">();</span><span class="w"></span>
<span class="c1">// ERROR!</span>
<span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">nuclear_plant</span>::<span class="n">Uranium</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">foo</span>: <span class="nb">None</span><span class="p">,</span><span class="w"> </span><span class="n">bar</span>: <span class="nb">None</span> <span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="234737535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234737535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234737535">(Apr 15 2021 at 19:26)</a>:</h4>
<p>I think there might be a way to express that by annotating <code>FromZeros</code> with <code>#[marker]</code> so third parties can add their own impls, but i'll need a few minutes to bang my head against it...</p>



<a name="234738397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234738397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234738397">(Apr 15 2021 at 19:31)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">crate</span><span class="w"> </span><span class="n">zerocopy</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[marker]</span><span class="w"> </span><span class="c1">// &lt;------ Important addition!</span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">FromZeros</span><span class="o">&lt;</span><span class="n">Context</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="w">    </span><span class="cp">#[repr(u8)]</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">enum</span> <span class="nc">Zero</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">Zero</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="k">u8</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="k">unsafe</span><span class="w"> </span><span class="k">impl</span><span class="o">&lt;</span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="n">Context</span><span class="o">&gt;</span><span class="w"> </span><span class="n">FromZeros</span><span class="o">&lt;</span><span class="n">Context</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Dst</span><span class="w"></span>
<span class="w">    </span><span class="k">where</span><span class="w"></span>
<span class="w">        </span><span class="n">Dst</span>: <span class="nc">BikeshedIntrinsicFrom</span><span class="o">&lt;</span><span class="p">[</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="kt">usize</span>::<span class="n">MAX</span><span class="p">],</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">Assume</span>::<span class="n">NOTHING</span><span class="o">&gt;</span><span class="w"></span>
<span class="w">    </span><span class="p">{}</span><span class="w"></span>

<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">zeroed</span><span class="o">&lt;</span><span class="n">Dst</span><span class="p">,</span><span class="w"> </span><span class="n">Context</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Dst</span><span class="w"></span>
<span class="w">    </span><span class="k">where</span><span class="w"></span>
<span class="w">        </span><span class="n">Dst</span>: <span class="nc">FromZeros</span><span class="o">&lt;</span><span class="n">Context</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">mem</span>::<span class="n">transmute</span><span class="p">([</span><span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="n">size_of</span>::<span class="o">&lt;</span><span class="bp">Self</span><span class="o">&gt;</span><span class="p">])</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="kr">macro</span><span class="w"> </span><span class="n">zeroed</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">struct</span> <span class="nc">Context</span><span class="p">;</span><span class="w"></span>
<span class="w">            </span><span class="n">zerocopy</span>::<span class="n">zeroed</span>::<span class="o">&lt;</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">Context</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>


<span class="k">crate</span><span class="w"> </span><span class="n">example</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[repr(C)]</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">FooBar</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">pub</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="n">foo</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"> </span><span class="c1">// private field!</span>
<span class="w">        </span><span class="k">pub</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="n">bar</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"> </span><span class="c1">// private field!</span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="c1">// with this impl, others can use `zeroed!()` to instantiate `FooBar`, even</span>
<span class="w">    </span><span class="c1">// though they can't see its fields</span>
<span class="w">    </span><span class="k">impl</span><span class="o">&lt;</span><span class="n">Context</span><span class="o">&gt;</span><span class="w"> </span><span class="n">zerocopy</span>::<span class="n">FromZeros</span><span class="o">&lt;</span><span class="n">Context</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">FooBar</span><span class="w"></span>
<span class="w">    </span><span class="k">where</span><span class="w"></span>
<span class="w">        </span><span class="n">FooBar</span>: <span class="nc">BikeshedIntrinsicFrom</span><span class="o">&lt;</span><span class="p">[</span><span class="n">zerocopy</span>::<span class="n">Zero</span><span class="p">;</span><span class="w"> </span><span class="kt">usize</span>::<span class="n">MAX</span><span class="p">],</span><span class="w"> </span><span class="n">Context</span><span class="p">,</span><span class="w"> </span><span class="n">Assume</span>::<span class="n">VISIBILITY</span><span class="o">&gt;</span><span class="w"></span>
<span class="w">    </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="234738756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234738756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234738756">(Apr 15 2021 at 19:33)</a>:</h4>
<p>(whoops, i copy-pasted a bit too much in that last impl, but I think I fixed the example)</p>



<a name="234739090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234739090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234739090">(Apr 15 2021 at 19:35)</a>:</h4>
<p>I think now you <em>do</em> bump  into coherence problems</p>



<a name="234739185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234739185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234739185">(Apr 15 2021 at 19:35)</a>:</h4>
<p><code>#[marker]</code> allows overlapping impls</p>



<a name="234739213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234739213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234739213">(Apr 15 2021 at 19:36)</a>:</h4>
<p>Ok, nvm then</p>



<a name="234739683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234739683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234739683">(Apr 15 2021 at 19:39)</a>:</h4>
<p>(btw, i'm <em>really</em> enjoying putting this design through the gauntlet; thanks for all the excellent challenges!)</p>



<a name="234739867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234739867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234739867">(Apr 15 2021 at 19:40)</a>:</h4>
<p>No problem</p>



<a name="234741038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234741038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Olivier FAURE <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234741038">(Apr 15 2021 at 19:47)</a>:</h4>
<p>I still have a lot of small issues with the intrinsic; but it does cover most realistic use cases. Hm.</p>



<a name="234896513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234896513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234896513">(Apr 16 2021 at 18:00)</a>:</h4>
<p>(I think <code>#[marker]</code> will be amazing for this kind of thing.  One <code>impl</code> for each case that's legal, then use that trait as a bound in other methods to ensure correctness.)</p>



<a name="234906298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Example%20of%20a%20public-facing%20API%3F/near/234906298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Example.20of.20a.20public-facing.20API.3F.html#234906298">(Apr 16 2021 at 19:13)</a>:</h4>
<p>I agree! And it'll be particularly nice if the proposed extension allowing <code>#[marker]</code> on traits with defaulted items is implemented! but baby steps...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>